﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_DISCIPLINE
    {
        private DateTime m_Date;
        private DateTime m_DateOccurred;
        private string m_DecideNumber;
        private string m_Description;
        private Guid m_DisciplineID;
        private string m_DisciplineName;
        private string m_EmployeeCode;
        private string m_FilePath;
        private string m_Form;
        private string m_Location;
        private string m_Notes;
        private string m_Person;
        private string m_Reason;
        private bool m_Settlement;
        private bool m_Violations;
        private string m_Witnesses;

        public HRM_PROCESS_DISCIPLINE()
        {
            this.m_DisciplineID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_DisciplineName = "";
            this.m_DateOccurred = DateTime.Now;
            this.m_Location = "";
            this.m_Description = "";
            this.m_Witnesses = "";
            this.m_Violations = true;
            this.m_Notes = "";
            this.m_Form = "";
            this.m_Settlement = true;
            this.m_Reason = "";
            this.m_Date = DateTime.Now;
            this.m_DecideNumber = "";
            this.m_Person = "";
            this.m_FilePath = "";
        }

        public HRM_PROCESS_DISCIPLINE(Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            this.m_DisciplineID = DisciplineID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_DisciplineName = DisciplineName;
            this.m_DateOccurred = DateOccurred;
            this.m_Location = Location;
            this.m_Description = Description;
            this.m_Witnesses = Witnesses;
            this.m_Violations = Violations;
            this.m_Notes = Notes;
            this.m_Form = Form;
            this.m_Settlement = Settlement;
            this.m_Reason = Reason;
            this.m_Date = Date;
            this.m_DecideNumber = DecideNumber;
            this.m_Person = Person;
            this.m_FilePath = FilePath;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { this.m_DisciplineID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(Guid DisciplineID)
        {
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid DisciplineID)
        {
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_DISCIPLINE_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid DisciplineID)
        {
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_DISCIPLINE_Delete", myParams, myValues);
        }

        public bool Exist(Guid DisciplineID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid DisciplineID)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineID = reader.GetGuid(reader.GetOrdinal("DisciplineID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid DisciplineID)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineID = reader.GetGuid(reader.GetOrdinal("DisciplineID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid DisciplineID)
        {
            string str = "";
            string[] myParams = new string[] { "@DisciplineID" };
            object[] myValues = new object[] { DisciplineID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_DISCIPLINE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_DisciplineID = reader.GetGuid(reader.GetOrdinal("DisciplineID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_DisciplineName = Convert.ToString(reader["DisciplineName"]);
                    this.m_DateOccurred = Convert.ToDateTime(reader["DateOccurred"]);
                    this.m_Location = Convert.ToString(reader["Location"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    this.m_Witnesses = Convert.ToString(reader["Witnesses"]);
                    this.m_Violations = Convert.ToBoolean(reader["Violations"]);
                    this.m_Notes = Convert.ToString(reader["Notes"]);
                    this.m_Form = Convert.ToString(reader["Form"]);
                    this.m_Settlement = Convert.ToBoolean(reader["Settlement"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    this.m_FilePath = Convert.ToString(reader["FilePath"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_DISCIPLINE_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_DISCIPLINE_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_DISCIPLINE_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_DISCIPLINE_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_DISCIPLINE_GetListByEmployee", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { this.m_DisciplineID, this.m_EmployeeCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { this.m_DisciplineID, this.m_EmployeeCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_DISCIPLINE_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_DISCIPLINE_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_DISCIPLINE", "JobCode", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { this.m_DisciplineID, this.m_EmployeeCode, this.m_DisciplineName, this.m_DateOccurred, this.m_Location, this.m_Description, this.m_Witnesses, this.m_Violations, this.m_Notes, this.m_Form, this.m_Settlement, this.m_Reason, this.m_Date, this.m_DecideNumber, this.m_Person, this.m_FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_DISCIPLINE_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid DisciplineID, string EmployeeCode, string DisciplineName, DateTime DateOccurred, string Location, string Description, string Witnesses, bool Violations, string Notes, string Form, bool Settlement, string Reason, DateTime Date, string DecideNumber, string Person, string FilePath)
        {
            string[] myParams = new string[] { "@DisciplineID", "@EmployeeCode", "@DisciplineName", "@DateOccurred", "@Location", "@Description", "@Witnesses", "@Violations", "@Notes", "@Form", "@Settlement", "@Reason", "@Date", "@DecideNumber", "@Person", "@FilePath" };
            object[] myValues = new object[] { DisciplineID, EmployeeCode, DisciplineName, DateOccurred, Location, Description, Witnesses, Violations, Notes, Form, Settlement, Reason, Date, DecideNumber, Person, FilePath };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_DISCIPLINE_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Date")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [DisplayName("DateOccurred"), Category("Column")]
        public DateTime DateOccurred
        {
            get
            {
                return this.m_DateOccurred;
            }
            set
            {
                this.m_DateOccurred = value;
            }
        }

        [Category("Column"), DisplayName("DecideNumber")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Primary Key"), DisplayName("DisciplineID")]
        public Guid DisciplineID
        {
            get
            {
                return this.m_DisciplineID;
            }
            set
            {
                this.m_DisciplineID = value;
            }
        }

        [Category("Column"), DisplayName("DisciplineName")]
        public string DisciplineName
        {
            get
            {
                return this.m_DisciplineName;
            }
            set
            {
                this.m_DisciplineName = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("FilePath"), Category("Column")]
        public string FilePath
        {
            get
            {
                return this.m_FilePath;
            }
            set
            {
                this.m_FilePath = value;
            }
        }

        [Category("Column"), DisplayName("Form")]
        public string Form
        {
            get
            {
                return this.m_Form;
            }
            set
            {
                this.m_Form = value;
            }
        }

        [DisplayName("Location"), Category("Column")]
        public string Location
        {
            get
            {
                return this.m_Location;
            }
            set
            {
                this.m_Location = value;
            }
        }

        [DisplayName("Notes"), Category("Column")]
        public string Notes
        {
            get
            {
                return this.m_Notes;
            }
            set
            {
                this.m_Notes = value;
            }
        }

        [DisplayName("Person"), Category("Column")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_DISCIPLINE";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("Reason"), Category("Column")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }

        [DisplayName("Settlement"), Category("Column")]
        public bool Settlement
        {
            get
            {
                return this.m_Settlement;
            }
            set
            {
                this.m_Settlement = value;
            }
        }

        [Category("Column"), DisplayName("Violations")]
        public bool Violations
        {
            get
            {
                return this.m_Violations;
            }
            set
            {
                this.m_Violations = value;
            }
        }

        [DisplayName("Witnesses"), Category("Column")]
        public string Witnesses
        {
            get
            {
                return this.m_Witnesses;
            }
            set
            {
                this.m_Witnesses = value;
            }
        }
    }
}

